<?php

use yii\helpers\Url;
$login = Yii::$app->admin->isGuest;
if ($login) {
    $url = Url::toRoute(['login/index']);
    header("Location: $url");
    exit;
}
?>
<!-- topbar starts -->
<header class="main-header">
    <!-- Logo -->
    <a href="javascript:;" class="logo">
        <!-- mini logo for sidebar mini 50x50 pixels -->
        <span class="logo-mini"><b><?php echo Yii::$app->params['webname']?></b></span>
        <!-- logo for regular state and mobile devices -->
        <span class="logo-lg"><b><?= Yii::$app->params["webname"]?></b></span>
    </a>
    <!-- Header Navbar: style can be found in header.less -->
    <nav class="navbar navbar-static-top" role="navigation">
        <!-- Sidebar toggle button-->
        <a href="#" class="sidebar-toggle" data-toggle="offcanvas" role="button">
            <span class="sr-only">Toggle navigation</span>
        </a>
        <div class="collapse navbar-collapse pull-left" id="navbar-collapse">
          <ul class="nav navbar-nav">
              <?php if (Yii::$app->admin->identity->username == 'admin') {?>
                <li><a href="<?= Url::toRoute(["/column/index"])?>">系统设置</a></li>
              <?php } ?>
          </ul>
        </div>        
        <div class="navbar-custom-menu">
            <ul class="nav navbar-nav">
                <li class="dropdown user user-menu">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <img src="<?= Yii::getAlias("@web")?>/dist/img/noavatar_big.gif" class="user-image" alt="User Image" />
                        <span class="hidden-xs"><?= Yii::$app->admin->identity->username?></span>
                    </a>
                    <ul class="dropdown-menu">
                        <!-- User image -->
                        <li class="user-header">
                            <img src="<?= Yii::getAlias("@web")?>/dist/img/noavatar_big.gif" class="img-circle" alt="User Image" />
                            <p>
                                <?= Yii::$app->admin->identity->username?>
                            </p>
                        </li>
                        <!-- Menu Body -->
                        <!-- Menu Footer-->
                        <li class="user-footer">
                            <div class="pull-left">
                                <a href="<?= Url::toRoute(["site/reset-password"])?>" class="btn btn-default btn-flat">修改密码</a>
                            </div>
                            <div class="pull-right">
                                <a href="<?= Url::toRoute(["login/logout"])?>" class="btn btn-default btn-flat">退出</a>
                            </div>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>
</header>